package com.softtown.common.utils;

import java.security.SecureRandom;
import java.util.Random;

/**
 * @version v1.0
 * @ProjectName: softtown-aioffice
 * @ClassName: VerCodeGenerateUtil
 * @Description: 生成随机6位数字工具类
 * @Author: fuming
 * @Date: 2019/7/11 9:23
 */
public class VerCodeGenerateUtil {
    private static final String SYMBOLS = "0123456789";
    private static final Random RANDOM = new SecureRandom();

    /**
     * @Title: generateVerCode
     * @Description: 生成6位随机数字
     * @param @param []
     * @return @return java.lang.String
     * @author fuming
     * @throws
     * @date 2019/7/12 19:27
     */
    public static String generateVerCode() {
        char[] nonceChars = new char[6];
        for (int index = 0; index < nonceChars.length; ++index) {
            nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
        }
        return new String(nonceChars);
    }
}
